﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace KaoShifuxi02
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void lg_Authenticate(object sender, AuthenticateEventArgs e)
        {
            var name = lg.UserName.Trim();
            var word = lg.Password.Trim();
            var sql = string.Format("select * from Users where Username='{0}'and Password='{1}'",name,word);
            var dt = Dbhelper.GetDataTable(sql);
            if (dt.Rows.Count == 1)
            {
                var row = dt.Rows[0];
                var isActived = (bool)row.ItemArray[3];
                var isDalatad = (bool)row.ItemArray[4];
                if (isDalatad)
                {
                    lblCommret.Text = "账号已经被注销或者删除，有问题请联系客服！";
                }
                else
                {
                    if (isActived)
                    {
                        Response.Redirect("default.aspx");
                    }
                    else
                    {
                        lblCommret.Text = "账号已经停用，请联系客服处理！";
                    }
                }
            }
            else
            {
                lblCommret.Text = "账号或者密码错误，请重试！";
            }
        }
    }
}